from django import template

register = template.Library()


@register.filter
def add_class(field, css_class):
    """
    为表单字段添加CSS类
    """
    return field.as_widget(attrs={"class": css_class})